package com.dorm.cj.dr.demo;

import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.WorkHandler;

/**
 * 接着定义一个消费者抽象类，后面我们所有自定义的消费者都需要继承这个抽象类，并实现 consume 方法（对获取的数据进行业务处理）
 * @param <MyEvent>
 */
public abstract class AbsEventConsumer<MyEvent> implements EventHandler<MyEvent>, WorkHandler<MyEvent> {
    @Override
    public void onEvent(MyEvent event, long sequence, boolean endOfBatch) throws Exception {
        this.onEvent(event);
    }

    @Override
    public void onEvent(MyEvent event) throws Exception {
        this.consume(event);
    }

    public abstract void consume(MyEvent event);
}
